<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
	<div id="teacher_managetb">
        <form id="teacher_manageForm" class="m5">
            年级：
            <select class="form-control1" name="grade" id="grade"></select>
            学科：
            <select class="form-control1" name="subjectId" id="subjectId"></select>
            教师姓名：
            <input class="form-control1" type="text" name="teacherName" id="teacherName">
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="searchForm('teacher_manage')">查询</a>
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm('teacher_manage')">重置</a><br/>
            
        </form>
    </div>
    <table id="teacher_managedg">
    	<thead frozen="true">
			<tr>
				<th data-options="field:'ID',checkbox:true">ID</th>
                <th data-options="field:'姓名',title:'姓名'"></th>
                <th data-options="field:'年级号',title:'年级号',formatter:function(value,row,index){
                    return row.gradeName;
                }"></th>
                <th data-options="field:'任教学科ID',title:'任教学科',formatter:function(value,row,index){
                    return row.subjectName;
                }"></th>
                <th data-options="field:'签到',title:'是否签到',formatter:function(value,row,index){
                    if(value == 1) return '是';
                    return '否';
                }"></th>
                <th data-options="field:'离校学期ID',title:'在校状态',width:50,sortable:true,formatter:function(value,row,index){
                    if(value > 0) {
                        var text = '';
                        if(value == 1) text = '调出';
                        else if(value == 2) text = '休假';
                        else if(value == 3) text = '离职';
                        return '<span style=\'color:red;\'>'+text+'</span>';
                    } else {
                        return '在校';
                    }
                }"></th>
			</tr>
		</thead>
        <thead>
            <tr>
                <th data-options="field:'手机号',title:'手机号'"></th>
                <th data-options="field:'身份证号',title:'身份证号'"></th>
                <th data-options="field:'登录密码',title:'登录密码'"></th>
                <th data-options="field:'性别',title:'性别'"></th>
                <th data-options="field:'出生日期',title:'出生日期'"></th>
                <th data-options="field:'positionText',title:'身份'"></th>
                <th data-options="field:'职称',title:'职称'"></th>
                <th data-options="field:'籍贯',title:'籍贯'"></th>
                <th data-options="field:'民族',title:'民族'"></th>
                <th data-options="field:'政治面貌',title:'政治面貌'"></th>
                <th data-options="field:'居住地址',title:'居住地址'"></th>
                <th data-options="field:'入党团时间',title:'入党团时间'"></th>
                <th data-options="field:'户口性质',title:'户口性质'"></th>
                <th data-options="field:'婚姻状况',title:'婚姻状况'"></th>
                <th data-options="field:'毕业参加工作时间',title:'毕业参加工作时间'"></th>
                <th data-options="field:'大学专业',title:'大学专业'"></th>
                <th data-options="field:'是否正编教师',title:'是否正编教师'"></th>
                <th data-options="field:'是否有普通话证',title:'是否有普通话证'"></th>
                <th data-options="field:'是否具备心理ABC证',title:'是否具备心理ABC证'"></th>
                <th data-options="field:'其他获得资格证书',title:'其他获得资格证书	'"></th>
                <th data-options="field:'曾获得荣誉',title:'曾获得荣誉'"></th>
            </tr>
        </thead>
    </table>
    <div id="uploadBox" style="display: none;height: auto;">
        <div class="m30">
            <form method="post" enctype="multipart/form-data" id="teacher_manageUploadForm" action="">
                <div class="mt20">
                    <input class="easyui-filebox" data-options="buttonText:'选择文件'" id="files" name="files" style="width:250px;">
                </div>
            </form>
        </div>
        <div class="tnc m20">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="uploadCommit('teacher_manage')" style="width: 200px;">上传</a>
        </div>
    </div>

    <script type="text/javascript">
        var url = "/teacher/teacher_manage";
        $(function(){
            initDatagrid("teacher_manage",url);
            initGrade("teacher_manage");
            initSubject("teacher_manage");
        })
        function initDatagrid(cf, url) {
        	var btnArr=[];
			btnArr.push({text:'增加',iconCls:'icon-add',handler:function(){
                    window.top["teacher_manage"]=function(){
                        dgObj.datagrid("reload");
                    };
					addTab('新增教师','teacherUpdate/0');
			}},'-');
			btnArr.push({text:'删除',iconCls:'icon-remove',handler:function(){del(cf, url)}},'-');
			btnArr.push({text:'修改',iconCls:'icon-edit',handler:function(){
					var dgObj=$('#teacher_managedg');
					var rows=dgObj.datagrid('getSelections');
					if(rows.length == 0) return;
					window.top["teacher_manage"]=function(){
						dgObj.datagrid("reload");
					};
					var url = "teacherUpdate/" + rows[0].ID;
					addTab('修改教师', url);
			}},'-');
			btnArr.push({text:'导出为EXCEL',iconCls:'icon-save',handler:function(){outExcel(cf,url)}},"-");
            btnArr.push({text:'下载EXCEL模板',iconCls:'icon-tip',handler:function(){downloadTemplate('教职员工信息花名册模板.xls')}},"-");
            btnArr.push({text:'导入',iconCls:'icon-large-smartart',handler:function(){importExcel('teacher_manage')}},"-");

			$("#teacher_managedg").datagrid({
				url: url + "/pageQuery.html",
				rownumbers: true,
				striped: true,
				border: false,
				pagination: true,
				pageSize: 30,
				fitColumns: true,
				autoRowHeight: false,
				singleSelect: true,
				fit: true,
				toolbar: btnArr
			})
			var tb = $("#"+cf+"tb").html();
			if(tb) {
				$(".datagrid-toolbar").prepend(tb);
				$("#"+cf+"tb").remove();
			}
		}
		 //function addTeacher() {
		// 	$('#dlg').dialog({
		// 		title : '教师信息',
		// 		modal : true,
		// 		width : 800,
		// 		height: 500,
		// 		top : 0,
		// 		draggable : true,
		// 		resizable : true
		// 	}).show();
		// }
        function importExcel(cf) {
            $('#uploadBox').dialog({
                title : '教职员工信息导入',
                modal : true,
                width : 400,
                top : 100,
                buttons : '#btns'
            }).show();
        }
        function uploadCommit(cf){
            // $.messager.progress({
            //     title : '提示',
            //     msg : '上传中，请稍候...'
            // });
            $('#teacher_manageUploadForm').form('submit',{
                url: url + "/importExcel.html",
                success:function(data){
                $.messager.progress('close');
                if(data == '000') {
                    $.messager.show({title:'操作提示', msg:"上传成功"});
                    $('#uploadBox').dialog("close");
                    searchForm('teacher_manage');
                    return;
                }
                $.messager.alert('提示', data);
            }})
        }
        function downloadTemplate(name){
            window.location.href = "__STATIC__/template/" + name;
        }
    </script>
</body>
</html>